<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String ctx = request.getContextPath();
    request.setAttribute("ctx", ctx);
%>
<html>
<head>
    <title>Title</title>
    <script src="${ctx}/bootstrap/jquery-1.9.1.min.js"></script>
    <script src="${ctx}/bootstrap/bootstrap.js"></script>
    <script src="${ctx}/bootstrap/jquery.validate.min.js"></script>
    <script src="${ctx}/bootstrap/messages_zh.js"></script>
    <script src="${ctx}/bootstrap/validate.js"></script>
    <link rel="stylesheet" href="css/index_work.css">
</head>
<body>
<form action="${ctx}/tolist.do">
    <input type="hidden" name="pageNum">
    姓名<input type="text" name="dname" value="${dianpu.dname}">
    <input type="submit" value="查询">
</form>
<a href="${ctx}/toadd.do">添加</a>
<table>
    <tr>
        <td>编号</td>
        <td>店铺名称</td>
        <td>创建时间</td>
        <td>图片</td>
        <td>销售商品</td>
        <td>详细</td>
    </tr>
    <c:forEach items="${page.list}" var="var" varStatus="vs">
        <tr>
            <td>${vs.index+page.startRow}</td>
            <td>${var.dname}</td>
            <td>${var.create_date}</td>
            <td>
                <img src="${var.img}" style="width: 20px;height: 20px">
            </td>
            <td>
                <c:forEach items="${var.shops}" var="va" varStatus="ss">
                    <c:if test="${ss.index>0}">
                        |
                    </c:if>
                    ${va.sname}
                </c:forEach>
            </td>
            <td><a href="${ctx}/toadd.do?did=${var.did}">修改</a></td>
        </tr>
    </c:forEach>
    <tr>
        <td colspan="10">
            <a href="##" onclick="fenye(1)">首页</a>
            <a href="##" onclick="fenye(${page.isFirstPage?1:page.prePage})">上一页</a>
            <a href="##" onclick="fenye(${page.isLastPage?page.pages:page.nextPage})">下一页</a>
            <a href="##" onclick="fenye(${page.pages})">尾页</a>
        </td>
    </tr>
</table>
<script>
    function fenye(pageNum) {
        $('[name=pageNum]').val(pageNum);
        $("form").submit();
    }
</script>
</body>
</html>
